/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package web;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import org.birrap.entities.VasosT;


/**
 *
 * @author Denver
 */
@FacesConverter(value = "vaso")
public class ConverterSelectOneListboxVasos implements Converter{
    
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
//        Object ret = null;
//        if (component instanceof SelectOneListbox) {
//            Object list = ((SelectOneListbox) component).getSubmittedValue();
//            List dl = (List) list;
//            for (Object o : dl) {
//                String id = "" + ((VasosT) o).getIdVaso();
//                if (value.equals(id)) {
//                    ret = o;
//                    break;
//                }
//            }
//        }
        VasosT ret = new VasosT();
        ret.setIdVaso(Integer.parseInt(value));
        return ret;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        String str = "";
        if (value instanceof VasosT) {
            str = "" + ((VasosT) value).getIdVaso();
        }
        return str;
    }
   
}
